package com.example.javamaday.offer;

public class GetOffer0107 {

    public static void main(String[] args) {

    }

    public void rotate(int[][] matrix) {
        int tRow = 0;
        int tCol = 0;
        int dRow = matrix.length - 1;
        int dCol = matrix[0].length - 1;
        while (tRow < dRow) {
            rotateMatrix(matrix, tRow++, tCol++, dRow--, dCol--);
        }
    }

    public void rotateMatrix(int[][] matrix, int tRow, int tCol, int dRow, int dCol) {
        int times = dRow - tRow;
        for (int i = 0; i < times; i++) {
            int temp = matrix[tRow][tCol + i];
            matrix[tRow][tCol + i] = matrix[dRow - i][tCol];
            matrix[dRow - i][tCol] = matrix[dRow][dCol - i];
            matrix[dRow][dCol - i] = matrix[tRow + i][dCol];
            matrix[tRow + i][dCol] = temp;
        }
    }


}
